home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / mac / files / t_sys5 / unixcpio.gz / unixnet.cpio / global.h < prev    next >
C/C++ Source or Header  |  1994-07-11  |  4KB  |  138 lines

  1.  
  2. /* Global definitions used by every source file.
  3.  * Some may be compiler dependent.
  4.  */
  5. #define MK_FP(seg,ofs)    ((void far *) \
  6.                (((unsigned long)(seg) << 16) | (unsigned)(ofs)))
  7. /*wa6ngo* Switch "a" and "b" below as these functions are called with
  8.       the offset as the first param and the segment as the second*/
  9. #define pokew(a,b,c)    (*((int  far*)MK_FP((b),(a))) = (int)(c))
  10. #define pokeb(a,b,c)    (*((char far*)MK_FP((b),(a))) = (char)(c))
  11. #define peekw(a,b)    (*((int  far*)MK_FP((b),(a))))
  12. #define peekb(a,b)    (*((char far*)MK_FP((b),(a))))
  13. #define movblock(so,ss,do,ds,c)    movedata(ss,so,ds,do,c)
  14.  
  15. #define outportw outport
  16. #define inportw inport
  17. #define index strchr
  18. #define rindex strrchr
  19.  
  20. /* Indexes into binmode in files.c; hook for compilers that have special
  21.  * open modes for binary files
  22.  */
  23. #define    READ_BINARY    0
  24. #define    WRITE_BINARY    1
  25. #define APPEND_BINARY   2
  26. extern char *binmode[];
  27.  
  28. /* not all compilers grok defined() */
  29. #ifdef NODEFINED
  30. #define defined(x) (x)
  31. #endif
  32.  
  33. /* These two lines assume that your compiler's longs are 32 bits and
  34.  * shorts are 16 bits. It is already assumed that chars are 8 bits,
  35.  * but it doesn't matter if they're signed or unsigned.
  36.  */
  37. typedef long int32;        /* 32-bit signed integer */
  38. typedef unsigned short int16;    /* 16-bit unsigned integer */
  39. #define    uchar(x) ((unsigned char)(x))
  40. #define    MAXINT16 65535        /* Largest 16-bit integer */
  41.  
  42. /* Since not all compilers support structure assignment, the ASSIGN()
  43.  * macro is used. This controls how it's actually implemented.
  44.  */
  45. #ifdef    NOSTRUCTASSIGN    /* Version for old compilers that don't support it */
  46. #define    ASSIGN(a,b)    memcpy((char *)&(a),(char *)&(b),sizeof(b));
  47. #else            /* Version for compilers that do */
  48. #define    ASSIGN(a,b)    ((a) = (b))
  49. #endif
  50.  
  51. /* Define null object pointer in case stdio.h isn't included */
  52. #ifndef    NULL
  53. /* General purpose NULL pointer */
  54. #ifdef ATARI_ST
  55. #define NULL (char *)0        /* MW does not like funny typecasts on void */
  56. #else
  57. #define NULL (void *)0
  58. #endif
  59. #endif
  60. #define    NULLCHAR (char *)0    /* Null character pointer */
  61. #define    NULLFP     (int (*)())0    /* Null pointer to function returning int */
  62. #define    NULLVFP     (void (*)())0    /* Null pointer to function returning void */
  63. #define    NULLFILE (FILE *)0    /* Null file pointer */
  64.  
  65. /* General purpose function macros */
  66. #define    min(x,y)    ((x)<(y)?(x):(y))    /* Lesser of two args */
  67. #define    max(x,y)    ((x)>(y)?(x):(y))    /* Greater of two args */
  68.  
  69. /* Convert an address to a LONG value for printing */
  70. #ifdef MSDOS
  71. long    ptr2long();            /* for fuzzy segment addresses */
  72. #else
  73. #define ptr2long(x)    ((long) (x))    /* typecast suffices for others */
  74. #endif
  75.  
  76. #ifdef    MPU8080    /* Assembler routines are available */
  77. int16 hinibble(),lonibble(),hibyte(),lobyte(),hiword(),loword();
  78.  
  79. #else
  80.  
  81. /* Extract a short from a long */
  82. /* According to my docs, this bug is fixed in MWC 3.0. (from 3.0.6 release
  83.    notes.) -- hyc */
  84. #if    (ATARI_ST && (MWC < 306))
  85. extern int Sixteen;
  86. #define hiword(x)    ((int16)((x) >> Sixteen)) /* hide compiler bug.. */
  87. #else
  88. #define hiword(x)    ((int16)((x) >> 16))
  89. #endif
  90. #define    loword(x)    ((int16)(x))
  91.  
  92. /* Extract a byte from a short */
  93. #define    hibyte(x)    (((x) >> 8) & 0xff)
  94. #define    lobyte(x)    ((x) & 0xff)
  95.  
  96. /* Extract nibbles from a byte */
  97. #define    hinibble(x)    (((x) >> 4) & 0xf)
  98. #define    lonibble(x)    ((x) & 0xf)
  99.  
  100. #endif
  101.  
  102. #if    (defined(SYS5) || (defined(ATARI_ST) && defined(LATTICE)))
  103. #define rindex    strrchr
  104. #define index    strchr
  105. #endif
  106.  
  107. /* Heavily used functions from the standard library */
  108. char *index(),*rindex(),*malloc(),*calloc(),*ctime(),*tmpnam();
  109.  
  110. #if    ATARI_ST && MICRORTX
  111. /* the 68000 processor won't let you disable interrupts in user mode
  112.  * therefore, a trap handler has been defined to do this, and it's
  113.  * installed as trap #5. The Mark Williams compiler generates a trap #5
  114.  * when you call the magic function "micro_rtx" (their multi-tasking
  115.  * executive).
  116.  * the trap handler returns the previous processor level as a char.
  117.  */
  118.  
  119. #define disable()    micro_rtx(6)
  120. #define restore(state)    micro_rtx(state)
  121.  
  122. /* a quick, non-checking free() function as a macro */
  123. #ifdef QFREE
  124. #define free(p)        ((char *) (p))[-1] |= 1;
  125. #endif
  126. #endif
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.